﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TagBasedResourceManagePlatform
{
    public class Framework
    {

        #region Singleton Support

        private static Framework _instance;
        public static Framework GetInstance()
        {
            if (_instance == null)
                _instance = new TagBasedResourceManagePlatform.Framework();

            return _instance;
        }

        #endregion

        #region Static Fields

        [ThreadStatic]
        private static Database.DatabaseInstance _threadDatabaseInstance;

        //Used for lasy initialization.
        private Configuration _configuration;

        #endregion

        #region Properties

        public Database.DatabaseInstance Database
        {
            get
            {
                if (_threadDatabaseInstance == null)
                {
                    _threadDatabaseInstance = new TagBasedResourceManagePlatform.Database.DatabaseInstance();
                }
                return _threadDatabaseInstance;
            }
        }

        public Configuration Configuration
        {
            get
            {
                return _configuration == null ? _configuration = new Configuration() : _configuration;
            }
        }

        #endregion

        #region Constructor

        internal Framework()
        {
            PrivateInitialize();
        }

        #endregion

        #region Public Functions

        public SearchResult Search(params string[] keywords)
        {
            return SearchResult.CreateResult(keywords);
        }

        #endregion

        #region Private Functions

        private void PrivateInitialize()
        {
        }
        #endregion
    }
}
